package com.yuanfeng.order.controller;

import com.yuanfeng.commoms.dto.PageUserTokenBeanDTO;
import com.yuanfeng.commoms.dto.userms.UserTokenBeanDTO;
import com.yuanfeng.commoms.util.ResponseResult;
import com.yuanfeng.order.dto.FinancialSettlementDTO;
import com.yuanfeng.order.dto.WaitOrderDTO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;
import java.util.Map;

/**
 * @ClassName OrderSettlementController
 * @Description 订单结算
 * @Author hyq
 * @Date 2023/7/6 9:23
 * @Version 1.0
 **/
@RestController
@RequestMapping("order/settlement")
public class OrderSettlementController extends BaseController{

    /**
     *结算单对应订单导出
     * @param paraMap
     * @param response
     * @return
     * @throws IOException
     * @throws ParseException
     */
    @PostMapping("/exportExcel")
    public ResponseResult exportExcel(@RequestBody Map<String, Object> paraMap, HttpServletResponse response) throws IOException, ParseException {
        ResponseResult result = orderSettlementService.exportExcel(paraMap,response);
        return result;
    }

    /**
     *商家提现未提现金额查询导出
     * @param param
     * @return
     */
    @PostMapping("/platform/getMerchantAmountExp")
    public ResponseResult getMerchantAmountExp(@RequestBody FinancialSettlementDTO param){
        ResponseResult result = orderSettlementService.getMerchantAmountExp(param);
        return result;
    }

    /**
     * 商家后台查询结算单列表
     * @param paraMap
     * @return
     */
    @PostMapping("/business/list")
    public ResponseResult businessList(@RequestBody Map<String, String> paraMap) {
        ResponseResult result = orderSettlementService.businessList(paraMap);
        return result;
    }

    /**
     * 商家导出excel
     * @param paraMap
     * @return
     */
    @PostMapping("/business/export/excel")
    public ResponseResult exportexcelSettlementBusiness(@RequestBody Map<String, String> paraMap){
        ResponseResult result = orderSettlementService.exportexcelSettlementBusiness(paraMap);
        return result;
    }

    /**
     * 商家结算详情
     * @param paraMap
     * @return
     */
    @PostMapping("/detail")
    public ResponseResult settlementDetail(@RequestBody Map<String, String> paraMap) {
        ResponseResult result = orderSettlementService.settlementDetail(paraMap);
        return result;
    }

    /**
     * 商家结算单对应订单
     * @param paraMap
     * @return
     */
    @PostMapping("/detail/base/orderInfo")
    public ResponseResult listBaseInfo(@RequestBody Map<String, Object> paraMap){
        ResponseResult result = orderSettlementService.listBaseInfo(paraMap);
        return result;
    }

    /**
     * 商家结算单对应退单
     * @param paraMap
     * @return
     */
    @PostMapping("/detail/return/orderInfo")
    public ResponseResult listReutrnOrder(@RequestBody Map<String, Object> paraMap){
        ResponseResult result = orderSettlementService.listReutrnOrder(paraMap);
        return result;
    }

    /**
     * 商家导出订单excel
     * @param paraMap
     * @return
     */
    @PostMapping("/platform/export/excel")
    public ResponseResult exportexcelSettlementBaseInfo(@RequestBody Map<String, Object> paraMap){
        ResponseResult result = orderSettlementService.exportexcelSettlementBaseInfo(paraMap);
        return result;
    }

    /**
     * 商家导出退单excel
     * @param paraMap
     * @return
     */
    @PostMapping("/platform/export/excel/returnList")
    public ResponseResult exportexcelSettlementReturnOrder(@RequestBody Map<String, Object> paraMap) {
        ResponseResult result = orderSettlementService.exportexcelSettlementReturnOrder(paraMap);
        return result;
    }

    /**
     * 商家自销等待结算金额
     * @param param
     * @return
     */
    @PostMapping("/wait/detail")
    public ResponseResult waitSettlement(@RequestBody UserTokenBeanDTO param) {
        ResponseResult result = orderSettlementService.waitSettlement(param);
        return result;
    }

    /**
     * 商家等待结算对应订单列表
     * @param param
     * @return
     */
    @PostMapping("/wait/order/list")
    public ResponseResult waitOrderList(@RequestBody WaitOrderDTO param) {
        ResponseResult result = orderSettlementService.waitOrderList(param);
        return result;
    }

    /**
     * 商家等待结算对应罚款列表
     * @param param
     * @return
     */
    @PostMapping("/wait/fine/list")
    public ResponseResult waitFineList(@RequestBody PageUserTokenBeanDTO param) {
        ResponseResult result = orderSettlementService.waitFineList(param);
        return result;
    }

    /**
     * 商家等待结算对应退款列表
     * @param param
     * @return
     */
    @PostMapping("/wait/return/list")
    public ResponseResult waitReturnList(@RequestBody WaitOrderDTO param) {
        ResponseResult result = orderSettlementService.waitReturnList(param);
        return result;
    }


    /**
     * 商家等待结算对应退款列表
     * @param param
     * @return
     */
    @PostMapping("/wait/dealerReturn/list")
    public ResponseResult waitDealerReturnList(@RequestBody WaitOrderDTO param) throws IllegalAccessException {
        ResponseResult result=orderSettlementService.waitDealerReturnList(param);
        return result;
    }


    /**
     * 商家等待结算对应对账单 订单列表
     */
    @PostMapping("/wait/dealerOrder/list")
    public ResponseResult waitDealerOrderList(@RequestBody WaitOrderDTO param) throws IllegalAccessException {
        ResponseResult result=orderSettlementService.waitDealerOrderList(param);
        return result;
    }

    /**
     * 商家提现未提现金额查询
     * @param param
     * @return
     */
    @PostMapping("/platform/getMerchantAmount")
    public ResponseResult getMerchantAmount(@RequestBody FinancialSettlementDTO param) throws IllegalAccessException {
        ResponseResult result=orderSettlementService.getMerchantAmount(param);
        return result;
    }

    /**
     * 修改结算信息(店铺名)
     *
     * @param map
     * @return
     */
    @PostMapping("/updateByMap")
    public ResponseResult updateOrderSettlementByMap(@RequestBody Map<String, Object> map) {
        ResponseResult result=orderSettlementService.updateOrderSettlementByMap(map);
        return result;
    }


    /**
     * 平台查询 结算单对应的退单列表 导出
     *
     * @param paraMap
     * @return
     */
    @PostMapping("/platForm/returnOrderInfoExcel")
    public ResponseResult platFormReturnorderinfoExcel(@RequestBody Map<String, Object> paraMap) {
        ResponseResult result=orderSettlementService.platFormReturnorderinfoExcel(paraMap);
        return result;
    }

    /**
     * 平台查询 结算单对应的退单列表
     *
     * @param paraMap
     * @return
     */
    @PostMapping("/platForm/returnOrderInfo")
    public ResponseResult platFormReturnorderinfo(@RequestBody Map<String, Object> paraMap) {
        ResponseResult result=orderSettlementService.platFormReturnorderinfo(paraMap);
        return result;
    }

    /**
     * 平台查询 结算单对应订单
     *
     * @param paraMap
     * @return
     */
    @PostMapping("platForm/baseOrderInfo")
    public ResponseResult platFormSettlementBaseorderinfo(@RequestBody Map<String, Object> paraMap) {
        ResponseResult result=orderSettlementService.listBaseorderinfo(paraMap);
        return result;
    }

    /**
     * 平台查询 结算单对应订单
     *
     * @param paraMap
     * @return
     */
    @PostMapping("/platForm/detail")
    public ResponseResult platFormSettlementdetail(@RequestBody Map<String, Object> paraMap) {
        ResponseResult result=orderSettlementService.platFormSettlementdetail(paraMap);
        return result;
    }


    /**
     * 平台查询 结算列表
     *
     * @param map
     * @return
     */
    @PostMapping("/platForm/list")
    public ResponseResult queryPlatFormListSettlement(@RequestBody Map<String, Object> map) {
        ResponseResult result=orderSettlementService.queryPlatFormListSettlement(map);
        return result;
    }

    /**
     * 平台查询 结算列表 导出
     *
     * @param map
     * @return
     */
    @PostMapping("/platForm/listExcel")
    public ResponseResult queryPlatFormListSettlementExcel(@RequestBody Map<String, Object> map) {
        ResponseResult result=orderSettlementService.queryPlatFormListSettlementExcel(map);
        return result;
    }

    /**
     * 供应商 对账单 退单列表
     * @param param
     * @return
     */
    @PostMapping("/wait/supperReturn/list")
    public ResponseResult waitSupperReturnList(@RequestBody WaitOrderDTO param) {
        ResponseResult result=orderSettlementService.waitSupperReturnList(param);
        return result;
    }
    /**
     * 供应商 对账单 订单列表
     */
    @PostMapping("/wait/supperOrder/list")
    public ResponseResult waitSupperOrderList(@RequestBody WaitOrderDTO param) {
        ResponseResult result = orderSettlementService.waitSupperOrderList(param);
        return result;
    }

    /**
     * 供应商 对账单 结算公式
     * @param param
     * @return
     */
    @PostMapping("/wait/supply/detail")
    public ResponseResult supplyWaitSettlement(@RequestBody UserTokenBeanDTO param) {
        ResponseResult result = orderSettlementService.supplyWaitSettlement(param);
        return result;
    }


    /**
     * 商家经销等待结算金额
     *
     * @param map
     * @return
     */
    @PostMapping("/wait/dealer/detail")
    public ResponseResult dealerWaitSettlement(@RequestBody Map<String, Object> map) {
        ResponseResult result=orderSettlementService.dealerWaitSettlement(map);
        return result;
    }

    /**
     * 生成结算单订单
     *
     * @param map
     * @return
     */
    @PostMapping("/confirmSettlement")
    public ResponseResult confirmSettlement(@RequestBody Map<Object, Object> map) {
        ResponseResult result = orderSettlementService.confirmSettlement(map);
        return result;
    }
}
